docs: onchain calls guide#15
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces the placeholder content brief for the onchain calls guide with a comprehensive how-to guide covering inter-canister calls in Motoko and Rust on ICP.
Changes:
- Added a complete guide covering query vs update calls, making calls in Motoko (
canister:nameimports) and Rust (Call::unbounded_wait/bounded_waitbuilder pattern), error handling, bounded vs unbounded wait strategies, and important caveats (payload limits, non-atomic execution, caller identity, reentrancy,canister_inspect_messagescope, cross-subnet latency). - Included cross-links to related guides (parallel calls, Candid, certified variables, inter-canister call security).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Review: Onchain CallsMust fix
Suggestions
Verified
|
- Remove unused CallErrorExt import from basic call example - Use ic_cdk::update re-export instead of ic_cdk_macros::update - Add canister discovery section (Motoko import, Rust init arg, hardcoded) - Add pub/sub pattern section with Motoko publisher/subscriber examples - Add third-party canister calling guidance in bounded wait section - Use realistic 5s timeout in bounded wait example - Make caller identity example instructive (use caller after await) - Add TODO for Rust pub/sub example in dfinity/examples
|
Feedback addressed:
|
… redesign - Rewrite canister discovery section to recommend icp-cli's automatic PUBLIC_CANISTER_ID:<name> environment variables as the primary approach - Show Rust (ic_cdk::api::env_var_value) and Motoko (Prim.envVar) patterns - Move init arguments and hardcoded principals to "Alternative approaches" - Add notes throughout about canister:name syntax being redesigned for icp-cli compatibility - Add note on pub/sub subscriber's canister:pub import
|
Feedback addressed (follow-up):
|
…eam notes - Replace Prim.envVar (internal mo:⛔ module) with Runtime.envVar from mo:core/Runtime — the public API available since motoko-core v2.1.0 - Add icp-cli docs and icp-cli icskill to upstream attribution comment
- Update pub/sub publisher example from mo:base/List (linked list) to mo:core/List (mutable growable array) for consistency with other examples - Fix caller identity example: pass ledger as parameter instead of using undefined LEDGER constant
Summary
Comprehensive how-to guide for making inter-canister calls on ICP:
canister:nameimports,try/catcherror handling)Call::unbounded_wait/bounded_waitbuilder pattern, clean/non-clean reject handling)PUBLIC_CANISTER_ID:<name>) as the recommended approach, with init arguments and hardcoded principals as alternativescanister_inspect_messagescope, cross-subnet latencyNotes:
canister:nameimport syntax is being redesigned for icp-cli compatibility — flagged with notes throughoutSync recommendation
Informed by
dfinity/portal—docs/building-apps/interact-with-canisters/advanced-calls.mdx,docs/building-apps/developer-tools/cdks/rust/intercanister.mdx, multi-canister icskill,dfinity/examplesmotoko/pub-sub, anddfinity/icp-clidocs/concepts/canister-discovery.md